/**
 * 
 */
package trungsi.gea.photos.domain;

import java.util.Date;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

/**
 * @author trungsi
 *
 */
@PersistenceCapable(identityType=IdentityType.APPLICATION)
public class Photo implements Entity {
	@PrimaryKey
	@Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)
	@Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
	private String id;
	@Persistent
	private String name;
	@Persistent(serialized="true")
	private byte[] photo;
	@Persistent(serialized="true")
	private byte[] thumbnail;
	@Persistent(serialized="true")
	private byte[] slideshow;
	@Persistent
	private Date createdDate = new Date();
	@Persistent
	//private Folder folder;
	private String folder;
	
	public String getId() {
		return id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Date getCreatedDate() {
		return createdDate;
	}
	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}
	
	public byte[] getPhoto() {
		return photo;
	}
	public void setPhoto(byte[] photo) {
		this.photo = photo;
	}
	public byte[] getThumbnail() {
		return thumbnail;
	}
	public void setThumbnail(byte[] thumbnail) {
		this.thumbnail = thumbnail;
	}
	
	//public void setFolder(Folder folder) {
		/*if (this.folder != null) {
			this.folder.removePhoto(this);
		}*/
		//this.folder = folder;
		//this.folder.addPhoto(this);
	//}
	
	/*public Folder getFolder() {
		return folder;
	}*/
	
	public void setSlideshow(byte[] bytes) {
		this.slideshow = bytes;
	}
	
	public String getFolder() {
		return folder;
	}
	public void setFolder(String folder) {
		this.folder = folder;
	}
	
	public byte[] getSlideshow() {
		return slideshow;
	}
	
	@Override
	public String toString() {
		return "Photo[name:" + name + ", id:" + id + ", created:" + createdDate + "]";
	}
}
